package utils;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBConnection {
	Connection conn;
	String url;
	String user;
	String pws;
	static {
		try {
			Class.forName("com.mysql.jdbc.Driver").newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	public DBConnection() {
		url = "jdbc:mysql://localhost/markit?useUnicode=true&characterEncoding=utf-8";
		user = "root";
		pws = "104814";
		conn = null;
	}

	public Connection getConnection() {
		try {
			conn = DriverManager.getConnection(url, user, pws);
		} catch (Exception e) {
			System.out.println("Error occurred obtaining connection");
			System.out.println(e);
		}
		return conn;
	}
}